#include "EffectBase.h"

namespace Rz { namespace Graphics { namespace Effects {

const Render::IEffect* EffectBase::GetEffect() const
{
	return _effect;
}
	
Render::IEffect* EffectBase::GetEffect()
{
	return _effect;
}

void EffectBase::SetEffect(Render::IEffect* effect)
{
	if (_effect == effect)
	{
		return;
	}

	_effect = effect;

	_effect->Bind();
	pProjectionMatrix			= _effect->CreateAndAddProperty("uProjectionMatrix");
	pViewMatrix					= _effect->CreateAndAddProperty("uViewMatrix");
	pModelMatrix				= _effect->CreateAndAddProperty("uModelMatrix");
	pProjectionViewMatrix		= _effect->CreateAndAddProperty("uProjectionViewMatrix");
	pProjectionViewModelMatrix	= _effect->CreateAndAddProperty("uProjectionViewModelMatrix");
	pNormalMatrix				= _effect->CreateAndAddProperty("uNormalMatrix");
	pEyeDirection				= _effect->CreateAndAddProperty("uEyeDirection");
	pEyePosition				= _effect->CreateAndAddProperty("uEyePosition");
	pWindowSize					= _effect->CreateAndAddProperty("uWindowSize");
	pNearFar					= _effect->CreateAndAddProperty("uNearFar");
}

EffectBase::EffectBase(Render::IRenderDevice* renderDevice)
{
	this->SetRenderDevice(renderDevice);
}

} } }
